package org.zzz.mapper;

import org.apache.ibatis.annotations.*;
import org.zzz.entity.TeacherCourse;

import java.util.List;

/**
 * @Author ZZF
 * @Time 2021/04/20 22:24
 */
public interface TeacherCourseMapper {
    /**
     * 添加教师课程
     * @param teacherCourse
     * @return
     */
    @Insert("insert into teacher_course value(#{id},#{tid},#{cid})")
    int insertTC(TeacherCourse teacherCourse);

    /**
     * 修改教师课程
     * @param teacherCourse
     * @return
     */
    @Update("update teacher_course set cid = #{cid},tid = #{tid} where id = #{id}")
    int updateTC(TeacherCourse teacherCourse);

    /**
     * 根据id删除教师课程
     * @param id
     * @return
     */
    @Delete("delete from teacher_course where id = #{id}")
    int deleteTCById(@Param("id") String id);


    /**
     * 根据教师id获取任课课程名称
     * @param tid
     * @return
     */
    @Select("select c.name from teacher_course tc,course c where tc.cid = c.id and tid = #{tid}")
    List<String> listCourseNameByTid(@Param("tid") String tid);

    @Select("select * from teacher_course where cid = #{cid}")
    TeacherCourse getTCByCid(@Param("cid") String cid);

    @Select("select * from teacher_course where tid = #{tid}")
    TeacherCourse getTCByTid(@Param("tid") String tid);
}
